package com.vd.tbsms.resource;

import java.io.FileInputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
 * @desc xls资源
 * @author tudongyun
 *
 */
public class XlsResource extends Resource {
	private Workbook workBook;
	public XlsResource(String uri, Type type) {
		super(uri, type);
	}
	public Workbook getWorkBook() throws Exception {
		synchronized (uri) {
			if(workBook != null){
				return workBook;
			}
			FileInputStream fps = new FileInputStream(uri);
			if(uri.endsWith("xls")){
				workBook = new HSSFWorkbook(fps);
			}else{
				workBook = new XSSFWorkbook(fps);
			}
		}
		return workBook;
	}
	
}
